package com.xkdx.guangguang.presistence.exchangeproduct;

import org.json.JSONArray;
import org.json.JSONObject;

import com.xkdx.guangguang.module.network.AbsModule;

public class ExchangeProductModule extends AbsModule {
	public ExchangePoint exchangePoint;
	@Override
	public void parseData() throws Exception {
			backJson = (JSONArray) result;
		try {
			for (int i = 0; i < backJson.length(); i++) {
				jsonObj = (JSONObject) backJson.get(i);
				String sortOfAct = jsonObj.getString("Act");
				if (sortOfAct.equals("ExchageProduct_v2")) {
					exchangePoint = parserexchangePoint(jsonObj.getJSONObject("Content"));
				}

			}
		} catch (Exception e) {
			throw e;
		}

	}

	// 实现最终的兑换积分
		private ExchangePoint parserexchangePoint(JSONObject person) throws Exception{
			ExchangePoint exchangePoint=new ExchangePoint();
			try {
				if (person == null) {
					return null;
				}
				JSONObject stut = (JSONObject) person.get("Result");
				exchangePoint.setMessage(stut.getString("Message"));
				exchangePoint.setStatus(stut.getString("Status"));
				if (stut.has("DetailInfo")) {
					JSONObject json = stut.getJSONObject("DetailInfo");
					exchangePoint.setUserPoint(json.getString("UserPoint"));
					exchangePoint.setProductCode(json.getString("ProductCode"));
					exchangePoint.setExchageCode(json.getString("ExchageCode"));
				}

			} catch (Exception e) {
				throw e;
			}
			return exchangePoint;
		}
		
		
		public class ExchangePoint {
			private String Message;
			private String Status;
			private String ProductCode;
			private String ExchageCode;
			private String UserPoint;

			public String getMessage() {
				return Message;
			}

			public void setMessage(String message) {
				Message = message;
			}

			public String getStatus() {
				return Status;
			}

			public void setStatus(String status) {
				Status = status;
			}

			public String getProductCode() {
				return ProductCode;
			}

			public void setProductCode(String productCode) {
				ProductCode = productCode;
			}

			public String getExchageCode() {
				return ExchageCode;
			}

			public void setExchageCode(String exchageCode) {
				ExchageCode = exchageCode;
			}

			public String getUserPoint() {
				return UserPoint;
			}

			public void setUserPoint(String userPoint) {
				UserPoint = userPoint;
			}

		}

	
}
